<template>
    <div>
        <!--五大功能-->
        <el-row style="margin: 0 auto 20px;">
            <el-menu mode="horizontal"
                     style="height: 60px;background-color: #cbf4e8;margin: 0 auto 20px;
                    padding-left: 35vw" @select="handleSelect">
                <el-menu-item class="el_row_span" index="1">问医生</el-menu-item>
                <el-menu-item class="el_row_span" index="2">查疫苗</el-menu-item>
                <el-menu-item class="el_row_span" index="3">医药百科</el-menu-item>
                <el-menu-item class="el_row_span" index="4">急救指南</el-menu-item>
                <el-menu-item class="el_row_span" index="5">科普视频</el-menu-item>
            </el-menu>
        </el-row>


        <!--外边灰框-->
        <div >
            <router-view/>
        </div>


    </div>
</template>

<style>
.el_row_span{
    text-align: center;
    text-decoration: none;

    font: 15px "微软雅黑 Light";
    line-height: 50px;
    margin: 0 5px 0 5px;
    display: inline-block;
    color: #4a4a4a;
}
</style>

<script>
import BaseUrl from "@/http/BaseUrl";
import TokenAxios from "@/http/TokenAxios";

export default {
    data(){
        return{
            dep:[],
            loginInfo:'',
        }
    },
    methods: {
        handleSelect(key, keyPath) {
            console.log(key,keyPath)
            switch (key){
                case "1":
                    if (this.loginInfo.role===2) {
                        location.href='/consult'
                    }else if(this.loginInfo.role===4){
                        location.href='/consult/chat?depId='+this.dep[0].department;
                    }else if(this.loginInfo.role===1){
                        location.href='/personal/user/info'
                    }else if(this.loginInfo.role===3){
                        location.href='/personal/doc/credential'
                    }
                    break;
                case "2":
                    location.href='/vaccine'
                    break;
                case "3":
                    location.href='/encyclopedia'
                    break;
                case "4":
                    location.href='/aid'
                    break;
                case "5":
                    location.href='/video'
                    break;
            }
        },
        loadCurrentLoginInfo(){
            this.loginInfo=JSON.parse(localStorage.getItem('loginInfo'));
            if (this.loginInfo.role===3||this.loginInfo.role===4){
                this.getDep();
            }
        },
        getDep(){
            let url=BaseUrl.CHAT+'/chat/getDep';
            console.log(url);

            TokenAxios.get(url).then((response)=>{
                // if (response.data.state===20000){
                this.dep=response.data.data;
                console.log(this.dep[0].department)
                // }
            })
        }
    },
    created() {

    },
    mounted() {
        this.loadCurrentLoginInfo();
    }
}
</script>